/*
 * @Descripttion: 页面适配
 * @version:
 * @Author: 周志国
 * @Date: 2021-07-26 09:30:32
 * @LastEditors: 周志国
 * @LastEditTime: 2021-07-28 09:53:46
 * @changeLog:
 * @FilePath: /anov-next/src/assets/js/app/indexhandler/pageAdapt.js
 */
import { sizeAdaptServer, envServer } from 'anov-core'

const adaptPages = {
  adaptApp: 'DOM_APP',
  adaptModal: 'DOM_MODAL'
}
function adaptApp_init() {
  adaptPages.adaptApp = sizeAdaptServer.create({
    wrapSelector: '#con',
    domSelector: '#app',
    sizeEqualRatio: true,
    w: envServer.designSize.w,
    h: envServer.designSize.h,
    resizeCallback: (minRatio) => {
      envServer.scaleRatio = minRatio
      envServer.displayResize()
    }
  })
  adaptPages.adaptApp?.resize()
}
function adaptApp_update() {
  adaptPages.adaptApp?.updateAdapt({
    w: envServer.designSize.w,
    h: envServer.designSize.h
  })
  adaptPages.adaptApp?.resize()
}
function adaptModal_init() {
  adaptPages.adaptModal = sizeAdaptServer.create({
    wrapSelector: '#con',
    domSelector: '#modalWrapper',
    sizeEqualRatio: true,
    w: envServer.designSize.w,
    h: envServer.designSize.h
  })
  adaptPages.adaptModal?.resize()
}
function adaptModal_update() {
  adaptPages.adaptModal.updateAdapt({
    w: envServer.designSize.w,
    h: envServer.designSize.h
  })
  adaptPages.adaptModal?.resize()
}
export {
  adaptApp_init,
  adaptApp_update,
  adaptModal_init,
  adaptModal_update,
  adaptPages
}
